using BootstrapBlazorApp.Server.LLMs.api;
using BootstrapBlazorApp.Server.LLMs.messages;

namespace BootstrapBlazorApp.Server.LLMs.chain;

public class ChainContext 
{
    //消息列表
    public List<IBaseMessage> MessagesList { get; set; } = [];
    //输入提示模板的字典
    public Dictionary<string, string> PromptInputValue { get; set; } = new();
    //字符串格式的输入
    public string InputContent { get; set; } = string.Empty;
    //链的输出
    public dynamic OutPutContent { get; set; } = string.Empty;
    //大模型的增量返回结果
    public string IncrementalOutput { get;set; } = string.Empty;


    public ChainContext()
    {
    }

    private ChainContext(Dictionary<string, string> input)
    {
        PromptInputValue = input;
    }

    private ChainContext(string inputContent)
    {
        InputContent = inputContent;
    }

    public void Add(IBaseMessage value)
    {
        MessagesList.Add(value);
    }

    public IBaseMessage GetLastMessage()
    {
        return MessagesList.Last();
    }

    public ChainContext(IBaseOutPutParser parser)
    {
        MessagesList.Add(new SystemMessage(parser.GetInstruction()));
    }

}
